package com.ruoyi.custservice.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bizsys.domain.CustReduceOrder;
import com.ruoyi.bizsys.service.ICustReduceOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户减免订单记录Controller
 *
 * @author african-loan
 * @date 2022-05-31
 */
@RestController
@RequestMapping("/bizsys/custReduceorder")
public class CustReduceOrderController extends BaseController {
    @Autowired
    private ICustReduceOrderService custReduceOrderService;

    /**
     * 查询客户减免订单记录列表
     */
    @PreAuthorize("@ss.hasPermi('bizsys:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(CustReduceOrder custReduceOrder) {
        startPage();
        List<CustReduceOrder> list = custReduceOrderService.selectCustReduceOrderList(custReduceOrder);
        return getDataTable(list);
    }

    /**
     * 导出客户减免订单记录列表
     */
    @PreAuthorize("@ss.hasPermi('bizsys:order:export')")
    @Log(title = "客户减免订单记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CustReduceOrder custReduceOrder) {
        List<CustReduceOrder> list = custReduceOrderService.selectCustReduceOrderList(custReduceOrder);
        ExcelUtil<CustReduceOrder> util = new ExcelUtil<CustReduceOrder>(CustReduceOrder.class);
        return util.exportExcel(list, "order");
    }

    /**
     * 获取客户减免订单记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('bizsys:order:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(custReduceOrderService.selectCustReduceOrderById(id));
    }

}
